import type {PageParam, PageResult} from '@vben/request';
import type {Dayjs} from 'dayjs';

import {requestClient} from '#/api/request';
export namespace PerBusinessFamilyInsuranceApi {
  /** 投资型保险情况业务信息 */
  export interface BusinessFamilyInsurance {
    id: number; // 主键ID
    busiId?: string; // 业务主表id
    famInsId: number; // 正式表ID，对应 per_family_insurance.id
    employeeId?: number; // 人员ID，对应 per_employee.id
    relation: string; // 与本人关系（称谓）
    systemPersonId: number; // 系统人员ID，对应 system_person.id
    familyName: string; // 家庭成员姓名
    cardType: string; // 证件类型
    familyIdcard: string; // 家庭成员身份证号
    insuranceNamePolicy: string; // 保险产品全称及保单号
    insuranceCompany: string; // 保险公司名称
    totalInvestPremium: number; // 累积缴纳保费投资金
    recordDate: string; // 记录时间
    status: number; // 是否有效（1：有效，0：无效）
    changeType: string; // 变更类型（add：新增，update：修改，delete：删除）
    changeContent: string; // 变更内容(JSON格式，记录变更前后对比，只有修改的时候记录)
    auditStatus: number; // 审核状态（0 草稿 1 审核中 2 审核完成）
    finalAuditStatus: number; // 最终审核状态：0 待审核 1 审核通过 2 审核不通过
    auditTime: string | Dayjs; // 审核完成时间
    auditor: string; // 审核人
    auditComment: string; // 审核意见
    metadata: string; // 其他参数
  }
}

/** 查询投资型保险情况业务分页 */
export function getBusinessFamilyInsurancePage(data: PageParam,desensitize: boolean,encrypt: boolean) {
  return requestClient.post<PageResult<PerBusinessFamilyInsuranceApi.BusinessFamilyInsurance>>('/per/business-family-insurance/page', data,{ desensitize,encrypt });
}

/** 查询投资型保险情况业务详情 */
export function getBusinessFamilyInsurance(id: number) {
  return requestClient.get<PerBusinessFamilyInsuranceApi.BusinessFamilyInsurance>(`/per/business-family-insurance/get?id=${id}`);
}

/** 新增投资型保险情况业务 */
export function createBusinessFamilyInsurance(data: PerBusinessFamilyInsuranceApi.BusinessFamilyInsurance) {
  return requestClient.post('/per/business-family-insurance/create', data);
}

/** 修改投资型保险情况业务 */
export function updateBusinessFamilyInsurance(data: PerBusinessFamilyInsuranceApi.BusinessFamilyInsurance) {
  return requestClient.put('/per/business-family-insurance/update', data);
}

/** 删除投资型保险情况业务 */
export function deleteBusinessFamilyInsurance(id: number) {
  return requestClient.delete(`/per/business-family-insurance/delete?id=${id}`);
}

/** 批量删除投资型保险情况业务 */
export function deleteBusinessFamilyInsuranceList(ids: number[]) {
  return requestClient.delete(`/per/business-family-insurance/delete-list?ids=${ids.join(',')}`)
}

/** 导出投资型保险情况业务 */
export function exportBusinessFamilyInsurance(params: any) {
  return requestClient.download('/per/business-family-insurance/export-excel', { params });
}

/** 根据业务主表id去查询业务数据 */
export function getFamilyInsuranceBusiId(data: any) {
  return requestClient.post<PerBusinessFamilyInsuranceApi.BusinessFamilyInsurance>(
    `/per/business-family-insurance/getFamilyInsuranceBusiId`,
    data,
  );
}

/** 获取当前登录人投资型保险情况 */
export function getCurrentFamilyInsurance(
  data: any,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<PerBusinessFamilyInsuranceApi.BusinessFamilyInsurance[]>(
    '/per/business-family-insurance/getCurrentFamilyInsurance',
    data,
    {
      desensitize,
      encrypt,
    },
  );
}
